﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Coleotrack.Core.Helper
{
    public static class Serializer<T>
    {
        public static T Deserialize(Stream stream)
        {
            stream.Position = 0;
            var xmlSerializer = new XmlSerializer(typeof(T));
            return (T)xmlSerializer.Deserialize(stream);
        }

        public static void Serialize(T entity, Stream stream)
        {
            stream.Position = 0;
            var xmlSerializer = new XmlSerializer(typeof (T));
            xmlSerializer.Serialize(stream, entity);
        }
    }
}
